package com.douqu.game.core.config.card;

import com.douqu.game.core.config.common.CommonData;
import com.douqu.game.core.entity.GameObject;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.util.LoadUtils;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2017-12-20 11:51
 */
public class CardStarAttributeConfig extends GameObject {

    public String icon, frameQuality;
    /**
     * 属性
     */
    public CommonData[] attribute;


    public int getAttribute(int attrId)
    {
        int result = 0;
        for(CommonData commonData : attribute)
        {
            if(commonData.id == attrId)
                result += commonData.value;
        }

        return result;
    }


    @Override
    public boolean setVariable(String key, String value)
    {
        if("attribute".equals(key))
        {
            attribute = LoadUtils.loadCommonDataToArray(key, value);
            return LoadUtils.checkCommonData(attribute, this.getClass(), key, DataFactory.ATTRIBUTE_KEY, id);
        }
        else
            return super.setVariable(key, value);
    }
}
